//
//  Configs.swift
//  newSwift
//
//  Created by Li on 2023/12/11.
//

import UIKit

struct Configs {
    
    /// 网络配置
    struct Network {
        private static let environment: Environment = .develop
        
    
        static var baseURL: String {
            switch environment {
            case .release:
                return ""
                
            case .pre:
                return ""
                
            case .test:
                return ""
            case .develop:
                return ""
            }
        }
        
       
        
        
        /// 环境配置
        private enum Environment {
            case release    // 发布
            case pre        // 预发布
            case test       // 测试
            case develop    // 开发 / 本地
        }
    }

    
    /// 基础尺寸
    struct BaseDimensions {
        
        static let inset: CGFloat = 10.rpx
        static let cornerRadius: CGFloat = 8.rpx
        static let borderWidth: CGFloat = 1
        static let viewHeight: CGFloat = 44.rpx
        /// 导航栏高度
        static let navBarHeight = statusBarHeight + navigationBarHeight
    }
    
    /// 常量
    struct Constant {
        /// 手机号长度
        static let phoneValidLength: Int = 11
        /// 验证码长度
        static let codeValidLength: Int = 6
        /// 密码最小长度
        static let pwdValidMinLength: Int = 8
        /// 密码最大长度
        static let pwdValidMaxLength: Int = 30
    }
    
    
    // APP配置
    struct App {
        static let identifier = Bundle.main.infoDictionary?["CFBundleIdentifier"] as? String ?? "Immers"
    }
}

/// 通知中心
public let notificationCenter: NotificationCenter = NotificationCenter.default


/// 日志输出
func Debug(_ items: Any..., separator: String = " ", terminator: String = "\n") {
#if DEBUG
    print(items, separator: separator, terminator: terminator)
#endif
}

func TLog(_ items: Any?..., file: String = #file, method: String = #function, line: Int = #line) {
#if DEBUG
    let dateFormat = DateFormatter()
    dateFormat.dateFormat = "MM-dd HH:mm:ss"
    let time = dateFormat.string(from: Date())
    print("time:", time)
    print(items)
    print("")
#endif
}

func QLog(_ items: Any?..., file: String = #file, method: String = #function, line: Int = #line) {
#if DEBUG
    let dateFormat = DateFormatter()
    dateFormat.dateFormat = "MM-dd HH:mm:ss"
    let time = dateFormat.string(from: Date())
    
    let start: String = "\n \n"+"""
--------------------     Time: \(time)     Log     ----------------------
文件名: \(file)
方法: \(method)
行号: \(line)
打印信息:
"""
    let info = items.reduce(start, { result, item in result + "\n\n" + "\(item ?? "nil")" })
    let end = info + "\n" + """

--------------------                  Log   END                ---------------------

"""
    print(end)
#endif
}
